-- ----------------------------
--  Table structure for `contacts`
-- ----------------------------
DROP TABLE IF EXISTS `contacts`;
CREATE TABLE `contacts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `provider_id` int(11) DEFAULT NULL,
  `name` varchar(50) NOT NULL,
  `address1` varchar(50) NOT NULL,
  `address2` varchar(50) NOT NULL,
  `address3` varchar(50) NOT NULL,
  `city` varchar(50) NOT NULL,
  `postal_code` varchar(10) NOT NULL,
  `phone_number` varchar(50) NOT NULL,
  `cell_number` varchar(50) NOT NULL,
  `fax_number` varchar(50) NOT NULL,
  `email_address` varchar(100) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `contacts_user_id_idx` (`user_id`),
  KEY `contacts_provider_id_idx` (`provider_id`),
  CONSTRAINT `contacts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
  CONSTRAINT `contacts_ibfk_2` FOREIGN KEY (`provider_id`) REFERENCES `providers` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- ----------------------------
--  Table structure for `countries`
-- ----------------------------
DROP TABLE IF EXISTS `countries`;
CREATE TABLE `countries` (
  `iso` varchar(3) NOT NULL,
  `name` varchar(80) NOT NULL,
  `printable_name` varchar(80) NOT NULL,
  `iso3` varchar(3) NOT NULL,
  `num_code` smallint(6) NOT NULL,
  PRIMARY KEY (`iso`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- ----------------------------
--  Records of `countries`
-- ----------------------------
BEGIN;
INSERT INTO `countries` VALUES ('AD', 'ANDORRA', 'Andorra', 'AND', '20'), ('AE', 'UNITED ARAB EMIRATES', 'United Arab Emirates', 'ARE', '784'), ('AF', 'AFGHANISTAN', 'Afghanistan', 'AFG', '4'), ('AG', 'ANTIGUA AND BARBUDA', 'Antigua and Barbuda', 'ATG', '28'), ('AI', 'ANGUILLA', 'Anguilla', 'AIA', '660'), ('AL', 'ALBANIA', 'Albania', 'ALB', '8'), ('AM', 'ARMENIA', 'Armenia', 'ARM', '51'), ('AN', 'NETHERLANDS ANTILLES', 'Netherlands Antilles', 'ANT', '530'), ('AO', 'ANGOLA', 'Angola', 'AGO', '24'), ('AQ', 'ANTARCTICA', 'Antarctica', '', '0'), ('AR', 'ARGENTINA', 'Argentina', 'ARG', '32'), ('AS', 'AMERICAN SAMOA', 'American Samoa', 'ASM', '16'), ('AT', 'AUSTRIA', 'Austria', 'AUT', '40'), ('AU', 'AUSTRALIA', 'Australia', 'AUS', '36'), ('AW', 'ARUBA', 'Aruba', 'ABW', '533'), ('AZ', 'AZERBAIJAN', 'Azerbaijan', 'AZE', '31'), ('BA', 'BOSNIA AND HERZEGOVINA', 'Bosnia and Herzegovina', 'BIH', '70'), ('BB', 'BARBADOS', 'Barbados', 'BRB', '52'), ('BD', 'BANGLADESH', 'Bangladesh', 'BGD', '50'), ('BE', 'BELGIUM', 'Belgium', 'BEL', '56'), ('BF', 'BURKINA FASO', 'Burkina Faso', 'BFA', '854'), ('BG', 'BULGARIA', 'Bulgaria', 'BGR', '100'), ('BH', 'BAHRAIN', 'Bahrain', 'BHR', '48'), ('BI', 'BURUNDI', 'Burundi', 'BDI', '108'), ('BJ', 'BENIN', 'Benin', 'BEN', '204'), ('BM', 'BERMUDA', 'Bermuda', 'BMU', '60'), ('BN', 'BRUNEI DARUSSALAM', 'Brunei Darussalam', 'BRN', '96'), ('BO', 'BOLIVIA', 'Bolivia', 'BOL', '68'), ('BR', 'BRAZIL', 'Brazil', 'BRA', '76'), ('BS', 'BAHAMAS', 'Bahamas', 'BHS', '44'), ('BT', 'BHUTAN', 'Bhutan', 'BTN', '64'), ('BV', 'BOUVET ISLAND', 'Bouvet Island', '', '0'), ('BW', 'BOTSWANA', 'Botswana', 'BWA', '72'), ('BY', 'BELARUS', 'Belarus', 'BLR', '112'), ('BZ', 'BELIZE', 'Belize', 'BLZ', '84'), ('CA', 'CANADA', 'Canada', 'CAN', '124'), ('CC', 'COCOS (KEELING) ISLANDS', 'Cocos (Keeling) Islands', '', '0'), ('CD', 'CONGO, THE DEMOCRATIC REPUBLIC OF THE', 'Congo, the Democratic Republic of the', 'COD', '180'), ('CF', 'CENTRAL AFRICAN REPUBLIC', 'Central African Republic', 'CAF', '140'), ('CG', 'CONGO', 'Congo', 'COG', '178'), ('CH', 'SWITZERLAND', 'Switzerland', 'CHE', '756'), ('CI', 'COTE D\'IVOIRE', 'Cote D\'Ivoire', 'CIV', '384'), ('CK', 'COOK ISLANDS', 'Cook Islands', 'COK', '184'), ('CL', 'CHILE', 'Chile', 'CHL', '152'), ('CM', 'CAMEROON', 'Cameroon', 'CMR', '120'), ('CN', 'CHINA', 'China', 'CHN', '156'), ('CO', 'COLOMBIA', 'Colombia', 'COL', '170'), ('CR', 'COSTA RICA', 'Costa Rica', 'CRI', '188'), ('CS', 'SERBIA AND MONTENEGRO', 'Serbia and Montenegro', '', '0'), ('CU', 'CUBA', 'Cuba', 'CUB', '192'), ('CV', 'CAPE VERDE', 'Cape Verde', 'CPV', '132'), ('CX', 'CHRISTMAS ISLAND', 'Christmas Island', '', '0'), ('CY', 'CYPRUS', 'Cyprus', 'CYP', '196'), ('CZ', 'CZECH REPUBLIC', 'Czech Republic', 'CZE', '203'), ('DE', 'GERMANY', 'Germany', 'DEU', '276'), ('DJ', 'DJIBOUTI', 'Djibouti', 'DJI', '262'), ('DK', 'DENMARK', 'Denmark', 'DNK', '208'), ('DM', 'DOMINICA', 'Dominica', 'DMA', '212'), ('DO', 'DOMINICAN REPUBLIC', 'Dominican Republic', 'DOM', '214'), ('DZ', 'ALGERIA', 'Algeria', 'DZA', '12'), ('EC', 'ECUADOR', 'Ecuador', 'ECU', '218'), ('EE', 'ESTONIA', 'Estonia', 'EST', '233'), ('EG', 'EGYPT', 'Egypt', 'EGY', '818'), ('EH', 'WESTERN SAHARA', 'Western Sahara', 'ESH', '732'), ('ER', 'ERITREA', 'Eritrea', 'ERI', '232'), ('ES', 'SPAIN', 'Spain', 'ESP', '724'), ('ET', 'ETHIOPIA', 'Ethiopia', 'ETH', '231'), ('FI', 'FINLAND', 'Finland', 'FIN', '246'), ('FJ', 'FIJI', 'Fiji', 'FJI', '242'), ('FK', 'FALKLAND ISLANDS (MALVINAS)', 'Falkland Islands (Malvinas)', 'FLK', '238'), ('FM', 'MICRONESIA, FEDERATED STATES OF', 'Micronesia, Federated States of', 'FSM', '583'), ('FO', 'FAROE ISLANDS', 'Faroe Islands', 'FRO', '234'), ('FR', 'FRANCE', 'France', 'FRA', '250'), ('GA', 'GABON', 'Gabon', 'GAB', '266'), ('GB', 'UNITED KINGDOM', 'United Kingdom', 'GBR', '826'), ('GD', 'GRENADA', 'Grenada', 'GRD', '308'), ('GE', 'GEORGIA', 'Georgia', 'GEO', '268'), ('GF', 'FRENCH GUIANA', 'French Guiana', 'GUF', '254'), ('GH', 'GHANA', 'Ghana', 'GHA', '288'), ('GI', 'GIBRALTAR', 'Gibraltar', 'GIB', '292'), ('GL', 'GREENLAND', 'Greenland', 'GRL', '304'), ('GM', 'GAMBIA', 'Gambia', 'GMB', '270'), ('GN', 'GUINEA', 'Guinea', 'GIN', '324'), ('GP', 'GUADELOUPE', 'Guadeloupe', 'GLP', '312'), ('GQ', 'EQUATORIAL GUINEA', 'Equatorial Guinea', 'GNQ', '226'), ('GR', 'GREECE', 'Greece', 'GRC', '300'), ('GS', 'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS', 'South Georgia and the South Sandwich Islands', '', '0'), ('GT', 'GUATEMALA', 'Guatemala', 'GTM', '320'), ('GU', 'GUAM', 'Guam', 'GUM', '316'), ('GW', 'GUINEA-BISSAU', 'Guinea-Bissau', 'GNB', '624'), ('GY', 'GUYANA', 'Guyana', 'GUY', '328'), ('HK', 'HONG KONG', 'Hong Kong', 'HKG', '344'), ('HM', 'HEARD ISLAND AND MCDONALD ISLANDS', 'Heard Island and Mcdonald Islands', '', '0'), ('HN', 'HONDURAS', 'Honduras', 'HND', '340'), ('HR', 'CROATIA', 'Croatia', 'HRV', '191'), ('HT', 'HAITI', 'Haiti', 'HTI', '332'), ('HU', 'HUNGARY', 'Hungary', 'HUN', '348'), ('ID', 'INDONESIA', 'Indonesia', 'IDN', '360'), ('IE', 'IRELAND', 'Ireland', 'IRL', '372'), ('IL', 'ISRAEL', 'Israel', 'ISR', '376'), ('IN', 'INDIA', 'India', 'IND', '356'), ('IO', 'BRITISH INDIAN OCEAN TERRITORY', 'British Indian Ocean Territory', '', '0'), ('IQ', 'IRAQ', 'Iraq', 'IRQ', '368'), ('IR', 'IRAN, ISLAMIC REPUBLIC OF', 'Iran, Islamic Republic of', 'IRN', '364'), ('IS', 'ICELAND', 'Iceland', 'ISL', '352'), ('IT', 'ITALY', 'Italy', 'ITA', '380'), ('JM', 'JAMAICA', 'Jamaica', 'JAM', '388'), ('JO', 'JORDAN', 'Jordan', 'JOR', '400'), ('JP', 'JAPAN', 'Japan', 'JPN', '392'), ('KE', 'KENYA', 'Kenya', 'KEN', '404'), ('KG', 'KYRGYZSTAN', 'Kyrgyzstan', 'KGZ', '417'), ('KH', 'CAMBODIA', 'Cambodia', 'KHM', '116'), ('KI', 'KIRIBATI', 'Kiribati', 'KIR', '296'), ('KM', 'COMOROS', 'Comoros', 'COM', '174'), ('KN', 'SAINT KITTS AND NEVIS', 'Saint Kitts and Nevis', 'KNA', '659'), ('KP', 'KOREA, DEMOCRATIC PEOPLE\'S REPUBLIC OF', 'Korea, Democratic People\'s Republic of', 'PRK', '408'), ('KR', 'KOREA, REPUBLIC OF', 'Korea, Republic of', 'KOR', '410'), ('KW', 'KUWAIT', 'Kuwait', 'KWT', '414'), ('KY', 'CAYMAN ISLANDS', 'Cayman Islands', 'CYM', '136'), ('KZ', 'KAZAKHSTAN', 'Kazakhstan', 'KAZ', '398'), ('LA', 'LAO PEOPLE\'S DEMOCRATIC REPUBLIC', 'Lao People\'s Democratic Republic', 'LAO', '418'), ('LB', 'LEBANON', 'Lebanon', 'LBN', '422'), ('LC', 'SAINT LUCIA', 'Saint Lucia', 'LCA', '662'), ('LI', 'LIECHTENSTEIN', 'Liechtenstein', 'LIE', '438'), ('LK', 'SRI LANKA', 'Sri Lanka', 'LKA', '144'), ('LR', 'LIBERIA', 'Liberia', 'LBR', '430'), ('LS', 'LESOTHO', 'Lesotho', 'LSO', '426'), ('LT', 'LITHUANIA', 'Lithuania', 'LTU', '440'), ('LU', 'LUXEMBOURG', 'Luxembourg', 'LUX', '442'), ('LV', 'LATVIA', 'Latvia', 'LVA', '428'), ('LY', 'LIBYAN ARAB JAMAHIRIYA', 'Libyan Arab Jamahiriya', 'LBY', '434'), ('MA', 'MOROCCO', 'Morocco', 'MAR', '504'), ('MC', 'MONACO', 'Monaco', 'MCO', '492'), ('MD', 'MOLDOVA, REPUBLIC OF', 'Moldova, Republic of', 'MDA', '498'), ('MG', 'MADAGASCAR', 'Madagascar', 'MDG', '450'), ('MH', 'MARSHALL ISLANDS', 'Marshall Islands', 'MHL', '584'), ('MK', 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF', 'Macedonia, the Former Yugoslav Republic of', 'MKD', '807'), ('ML', 'MALI', 'Mali', 'MLI', '466'), ('MM', 'MYANMAR', 'Myanmar', 'MMR', '104'), ('MN', 'MONGOLIA', 'Mongolia', 'MNG', '496'), ('MO', 'MACAO', 'Macao', 'MAC', '446'), ('MP', 'NORTHERN MARIANA ISLANDS', 'Northern Mariana Islands', 'MNP', '580'), ('MQ', 'MARTINIQUE', 'Martinique', 'MTQ', '474'), ('MR', 'MAURITANIA', 'Mauritania', 'MRT', '478'), ('MS', 'MONTSERRAT', 'Montserrat', 'MSR', '500'), ('MT', 'MALTA', 'Malta', 'MLT', '470'), ('MU', 'MAURITIUS', 'Mauritius', 'MUS', '480'), ('MV', 'MALDIVES', 'Maldives', 'MDV', '462'), ('MW', 'MALAWI', 'Malawi', 'MWI', '454'), ('MX', 'MEXICO', 'Mexico', 'MEX', '484'), ('MY', 'MALAYSIA', 'Malaysia', 'MYS', '458'), ('MZ', 'MOZAMBIQUE', 'Mozambique', 'MOZ', '508'), ('NA', 'NAMIBIA', 'Namibia', 'NAM', '516'), ('NC', 'NEW CALEDONIA', 'New Caledonia', 'NCL', '540'), ('NE', 'NIGER', 'Niger', 'NER', '562'), ('NF', 'NORFOLK ISLAND', 'Norfolk Island', 'NFK', '574'), ('NG', 'NIGERIA', 'Nigeria', 'NGA', '566'), ('NI', 'NICARAGUA', 'Nicaragua', 'NIC', '558'), ('NL', 'NETHERLANDS', 'Netherlands', 'NLD', '528'), ('NO', 'NORWAY', 'Norway', 'NOR', '578'), ('NP', 'NEPAL', 'Nepal', 'NPL', '524'), ('NR', 'NAURU', 'Nauru', 'NRU', '520'), ('NU', 'NIUE', 'Niue', 'NIU', '570'), ('NZ', 'NEW ZEALAND', 'New Zealand', 'NZL', '554'), ('OM', 'OMAN', 'Oman', 'OMN', '512'), ('PA', 'PANAMA', 'Panama', 'PAN', '591'), ('PE', 'PERU', 'Peru', 'PER', '604'), ('PF', 'FRENCH POLYNESIA', 'French Polynesia', 'PYF', '258'), ('PG', 'PAPUA NEW GUINEA', 'Papua New Guinea', 'PNG', '598'), ('PH', 'PHILIPPINES', 'Philippines', 'PHL', '608'), ('PK', 'PAKISTAN', 'Pakistan', 'PAK', '586'), ('PL', 'POLAND', 'Poland', 'POL', '616'), ('PM', 'SAINT PIERRE AND MIQUELON', 'Saint Pierre and Miquelon', 'SPM', '666'), ('PN', 'PITCAIRN', 'Pitcairn', 'PCN', '612'), ('PR', 'PUERTO RICO', 'Puerto Rico', 'PRI', '630'), ('PS', 'PALESTINIAN TERRITORY, OCCUPIED', 'Palestinian Territory, Occupied', '', '0'), ('PT', 'PORTUGAL', 'Portugal', 'PRT', '620'), ('PW', 'PALAU', 'Palau', 'PLW', '585'), ('PY', 'PARAGUAY', 'Paraguay', 'PRY', '600'), ('QA', 'QATAR', 'Qatar', 'QAT', '634'), ('RE', 'REUNION', 'Reunion', 'REU', '638'), ('RO', 'ROMANIA', 'Romania', 'ROM', '642'), ('RU', 'RUSSIAN FEDERATION', 'Russian Federation', 'RUS', '643'), ('RW', 'RWANDA', 'Rwanda', 'RWA', '646'), ('SA', 'SAUDI ARABIA', 'Saudi Arabia', 'SAU', '682'), ('SB', 'SOLOMON ISLANDS', 'Solomon Islands', 'SLB', '90'), ('SC', 'SEYCHELLES', 'Seychelles', 'SYC', '690'), ('SD', 'SUDAN', 'Sudan', 'SDN', '736'), ('SE', 'SWEDEN', 'Sweden', 'SWE', '752'), ('SG', 'SINGAPORE', 'Singapore', 'SGP', '702'), ('SH', 'SAINT HELENA', 'Saint Helena', 'SHN', '654'), ('SI', 'SLOVENIA', 'Slovenia', 'SVN', '705'), ('SJ', 'SVALBARD AND JAN MAYEN', 'Svalbard and Jan Mayen', 'SJM', '744'), ('SK', 'SLOVAKIA', 'Slovakia', 'SVK', '703'), ('SL', 'SIERRA LEONE', 'Sierra Leone', 'SLE', '694'), ('SM', 'SAN MARINO', 'San Marino', 'SMR', '674'), ('SN', 'SENEGAL', 'Senegal', 'SEN', '686'), ('SO', 'SOMALIA', 'Somalia', 'SOM', '706'), ('SR', 'SURINAME', 'Suriname', 'SUR', '740'), ('ST', 'SAO TOME AND PRINCIPE', 'Sao Tome and Principe', 'STP', '678'), ('SV', 'EL SALVADOR', 'El Salvador', 'SLV', '222'), ('SY', 'SYRIAN ARAB REPUBLIC', 'Syrian Arab Republic', 'SYR', '760'), ('SZ', 'SWAZILAND', 'Swaziland', 'SWZ', '748'), ('TC', 'TURKS AND CAICOS ISLANDS', 'Turks and Caicos Islands', 'TCA', '796'), ('TD', 'CHAD', 'Chad', 'TCD', '148'), ('TF', 'FRENCH SOUTHERN TERRITORIES', 'French Southern Territories', '', '0'), ('TG', 'TOGO', 'Togo', 'TGO', '768'), ('TH', 'THAILAND', 'Thailand', 'THA', '764'), ('TJ', 'TAJIKISTAN', 'Tajikistan', 'TJK', '762'), ('TK', 'TOKELAU', 'Tokelau', 'TKL', '772'), ('TL', 'TIMOR-LESTE', 'Timor-Leste', '', '0'), ('TM', 'TURKMENISTAN', 'Turkmenistan', 'TKM', '795'), ('TN', 'TUNISIA', 'Tunisia', 'TUN', '788'), ('TO', 'TONGA', 'Tonga', 'TON', '776'), ('TR', 'TURKEY', 'Turkey', 'TUR', '792'), ('TT', 'TRINIDAD AND TOBAGO', 'Trinidad and Tobago', 'TTO', '780'), ('TV', 'TUVALU', 'Tuvalu', 'TUV', '798'), ('TW', 'TAIWAN, PROVINCE OF CHINA', 'Taiwan, Province of China', 'TWN', '158'), ('TZ', 'TANZANIA, UNITED REPUBLIC OF', 'Tanzania, United Republic of', 'TZA', '834'), ('UA', 'UKRAINE', 'Ukraine', 'UKR', '804'), ('UG', 'UGANDA', 'Uganda', 'UGA', '800'), ('UM', 'UNITED STATES MINOR OUTLYING ISLANDS', 'United States Minor Outlying Islands', '', '0'), ('US', 'UNITED STATES', 'United States', 'USA', '840'), ('UY', 'URUGUAY', 'Uruguay', 'URY', '858'), ('UZ', 'UZBEKISTAN', 'Uzbekistan', 'UZB', '860'), ('VA', 'HOLY SEE (VATICAN CITY STATE)', 'Holy See (Vatican City State)', 'VAT', '336'), ('VC', 'SAINT VINCENT AND THE GRENADINES', 'Saint Vincent and the Grenadines', 'VCT', '670'), ('VE', 'VENEZUELA', 'Venezuela', 'VEN', '862'), ('VG', 'VIRGIN ISLANDS, BRITISH', 'Virgin Islands, British', 'VGB', '92'), ('VI', 'VIRGIN ISLANDS, U.S.', 'Virgin Islands, U.s.', 'VIR', '850'), ('VN', 'VIET NAM', 'Viet Nam', 'VNM', '704'), ('VU', 'VANUATU', 'Vanuatu', 'VUT', '548'), ('WF', 'WALLIS AND FUTUNA', 'Wallis and Futuna', 'WLF', '876'), ('WS', 'SAMOA', 'Samoa', 'WSM', '882'), ('YE', 'YEMEN', 'Yemen', 'YEM', '887'), ('YT', 'MAYOTTE', 'Mayotte', '', '0'), ('ZA', 'SOUTH AFRICA', 'South Africa', 'ZAF', '710'), ('ZM', 'ZAMBIA', 'Zambia', 'ZMB', '894'), ('ZW', 'ZIMBABWE', 'Zimbabwe', 'ZWE', '716');
COMMIT;

-- ----------------------------
--  Table structure for `flags`
-- ----------------------------
DROP TABLE IF EXISTS `flags`;
CREATE TABLE `flags` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  `description` varchar(250) NOT NULL,
  `active_on_dev` smallint(6) DEFAULT NULL,
  `active_on_prod` smallint(6) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=latin1;

-- ----------------------------
--  Records of `flags`
-- ----------------------------
BEGIN;
INSERT INTO `flags` VALUES ('1', 'backoffice-users', 'Allows user to manage the user groups', '1', '0'), ('2', 'backoffice-profile', 'Allows developers to manage the user groups', '1', '0'), ('3', 'backoffice-testing', 'Activate some testing functionalities', '1', '0'), ('4', 'frontend-testing', 'Activate some testing functionalities', '1', '0'), ('9', 'backoffice-flag', 'Allows the user to manage the flags', '1', '0'), ('10', 'backoffice-group', 'Allows the user to manage the groups', '1', '0'), ('11', 'backoffice-helpdesk', 'Able to view tickets assigned to the currently logged in use', '1', '0'), ('12', 'backoffice-privilege', '', '1', null), ('13', 'backoffice-flipper', '', '1', null), ('14', 'backoffice-async', '', '1', '0'), ('15', 'backoffice-index', '', '1', null);
COMMIT;

-- ----------------------------
--  Table structure for `flipper`
-- ----------------------------
DROP TABLE IF EXISTS `flipper`;
CREATE TABLE `flipper` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `allow` smallint(6) NOT NULL,
  `group_id` int(11) DEFAULT NULL,
  `flag_id` int(11) DEFAULT NULL,
  `privilege_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `flipper_group_id_idx` (`group_id`),
  KEY `flipper_flag_id_idx` (`flag_id`),
  KEY `flipper_privilege_id_idx` (`privilege_id`),
  CONSTRAINT `flipper_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`),
  CONSTRAINT `flipper_ibfk_2` FOREIGN KEY (`flag_id`) REFERENCES `flags` (`id`),
  CONSTRAINT `flipper_ibfk_3` FOREIGN KEY (`privilege_id`) REFERENCES `privileges` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=132 DEFAULT CHARSET=latin1;

-- ----------------------------
--  Records of `flipper`
-- ----------------------------
BEGIN;
INSERT INTO `flipper` VALUES ('1', '1', '1', '1', '1'), ('2', '1', '1', '1', '2'), ('3', '1', '1', '1', '3'), ('4', '1', '1', '1', '4'), ('5', '1', '1', '3', '5'), ('9', '1', '2', '1', '1'), ('10', '1', '2', '1', '2'), ('11', '1', '2', '1', '3'), ('12', '0', '2', '1', '4'), ('13', '1', '1', '9', '24'), ('14', '1', '1', '10', '25'), ('15', '1', '1', '10', '26'), ('16', '1', '1', '10', '27'), ('17', '1', '1', '10', '28'), ('18', '1', '1', '12', '29'), ('19', '1', '1', '12', '30'), ('20', '1', '1', '12', '31'), ('21', '1', '1', '12', '32'), ('22', '1', '1', '14', '35'), ('23', '1', '1', '11', '33'), ('24', '1', '1', '11', '34'), ('25', '1', '1', '10', '37'), ('26', '1', '1', '11', '36'), ('27', '1', '1', '14', '38'), ('28', '1', '2', '14', '35'), ('29', '1', '2', '14', '38'), ('30', '0', '2', '9', '24'), ('31', '0', '2', '10', '25'), ('32', '0', '2', '10', '26'), ('33', '0', '2', '10', '27'), ('34', '0', '2', '10', '28'), ('35', '0', '2', '10', '37'), ('36', '1', '2', '11', '33'), ('37', '1', '2', '11', '34'), ('38', '1', '2', '11', '36'), ('39', '0', '2', '12', '29'), ('40', '0', '2', '12', '30'), ('41', '0', '2', '12', '31'), ('42', '0', '2', '12', '32'), ('43', '0', '2', '3', '5'), ('44', '1', '3', '14', '35'), ('45', '1', '3', '14', '38'), ('46', '0', '3', '9', '24'), ('47', '0', '3', '10', '25'), ('48', '0', '3', '10', '26'), ('49', '0', '3', '10', '27'), ('50', '0', '3', '10', '28'), ('51', '0', '3', '10', '37'), ('52', '1', '3', '11', '33'), ('53', '1', '3', '11', '34'), ('54', '1', '3', '11', '36'), ('55', '0', '3', '12', '29'), ('56', '0', '3', '12', '30'), ('57', '0', '3', '12', '31'), ('58', '0', '3', '12', '32'), ('59', '0', '3', '3', '5'), ('60', '0', '3', '1', '1'), ('61', '0', '3', '1', '2'), ('62', '0', '3', '1', '3'), ('63', '0', '3', '1', '4'), ('64', '1', '3', '1', '39'), ('65', '1', '3', '1', '40'), ('66', '1', '2', '1', '39'), ('67', '1', '2', '1', '40'), ('68', '1', '1', '1', '39'), ('69', '1', '1', '1', '40'), ('70', '0', '4', '14', '35'), ('71', '0', '4', '14', '38'), ('72', '0', '4', '9', '24'), ('73', '0', '4', '10', '25'), ('74', '0', '4', '10', '26'), ('75', '0', '4', '10', '27'), ('76', '0', '4', '10', '28'), ('77', '0', '4', '10', '37'), ('78', '0', '4', '11', '33'), ('79', '0', '4', '11', '34'), ('80', '0', '4', '11', '36'), ('81', '0', '4', '12', '29'), ('82', '0', '4', '12', '30'), ('83', '0', '4', '12', '31'), ('84', '0', '4', '12', '32'), ('85', '0', '4', '3', '5'), ('86', '0', '4', '1', '1'), ('87', '0', '4', '1', '2'), ('88', '0', '4', '1', '3'), ('89', '0', '4', '1', '4'), ('90', '1', '4', '1', '39'), ('91', '0', '4', '1', '40'), ('92', '1', '3', '1', '40'), ('93', '1', '2', '15', '41'), ('94', '1', '1', '15', '41'), ('95', '1', '3', '15', '41'), ('96', '1', '1', '9', '44'), ('97', '1', '1', '9', '45'), ('98', '1', '1', '9', '46'), ('99', '1', '1', '1', '42'), ('100', '1', '1', '9', '47'), ('101', '1', '1', '2', '48'), ('102', '1', '1', '2', '49'), ('103', '0', '2', '9', '44'), ('104', '0', '2', '9', '45'), ('105', '0', '2', '9', '46'), ('106', '0', '2', '9', '47'), ('107', '1', '2', '2', '48'), ('108', '1', '2', '2', '49'), ('109', '0', '2', '1', '42'), ('110', '0', '3', '9', '44'), ('111', '0', '3', '9', '45'), ('112', '0', '3', '9', '46'), ('113', '0', '3', '9', '47'), ('114', '1', '3', '2', '48'), ('115', '1', '3', '2', '49'), ('116', '0', '3', '1', '42'), ('117', '1', '1', '11', '50'), ('118', '1', '1', '11', '38'), ('119', '1', '2', '11', '38'), ('120', '1', '2', '11', '50'), ('121', '1', '3', '11', '38'), ('122', '1', '3', '11', '50'), ('123', '1', '1', '11', '51'), ('124', '1', '1', '11', '52'), ('125', '1', '2', '11', '51'), ('126', '1', '2', '11', '52'), ('127', '1', '2', '11', '53'), ('128', '1', '1', '11', '53'), ('129', '1', '3', '11', '51'), ('130', '1', '3', '11', '52'), ('131', '1', '3', '11', '53');
COMMIT;

-- ----------------------------
--  Table structure for `groups`
-- ----------------------------
DROP TABLE IF EXISTS `groups`;
CREATE TABLE `groups` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `parent_id` int(11) DEFAULT NULL,
  `name` varchar(80) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `groups_parent_id_idx` (`parent_id`),
  CONSTRAINT `groups_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `groups` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

-- ----------------------------
--  Records of `groups`
-- ----------------------------
BEGIN;
INSERT INTO `groups` VALUES ('1', '2', 'developers'), ('2', '3', 'administrators'), ('3', '4', 'users'), ('4', null, 'guests');
COMMIT;

-- ----------------------------
--  Table structure for `privileges`
-- ----------------------------
DROP TABLE IF EXISTS `privileges`;
CREATE TABLE `privileges` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `flag_id` int(11) DEFAULT NULL,
  `name` varchar(50) NOT NULL,
  `description` varchar(250) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `privileges_flag_id_idx` (`flag_id`),
  CONSTRAINT `privileges_ibfk_1` FOREIGN KEY (`flag_id`) REFERENCES `flags` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=54 DEFAULT CHARSET=latin1;

-- ----------------------------
--  Records of `privileges`
-- ----------------------------
BEGIN;
INSERT INTO `privileges` VALUES ('1', '1', 'index', 'Allows the user to view all other users that are registered'), ('2', '1', 'create', 'Allows the user to add new users in the application'), ('3', '1', 'edit', "Allows user to edit another user\'s data"), ('4', '1', 'delete', 'Allows the user to logically delete other users'), ('5', '3', 'zfdebug', 'Enable ZF Debug Toolbar'), ('24', '9', 'index', 'Allows the user to view all flags that are registered'), ('25', '10', 'index', 'Allows the user to view all groups on the system'), ('26', '10', 'update', 'Allows the user to update group details'), ('27', '10', 'create', 'Allows the user to create a group'), ('28', '10', 'delete', 'Allows the user to delete a group'), ('29', '12', 'index', 'Allows the user to view all privileges on the system'), ('30', '12', 'create', 'Allows the user to create a privilege'), ('31', '12', 'delete', 'Allows the user to delete a privilege'), ('32', '12', 'update', 'Allows the user to update privilege details'), ('33', '11', 'index', 'Allows the user to view their own ticket inbox'), ('34', '11', 'new-ticket', 'Allows the user to create a new ticket'), ('35', '14', 'contact-search', 'Allows the user to search for a contact from their address book, or the provider address book'), ('36', '11', 'provider-inbox', 'Allows the user to view the provider inbox'), ('37', '10', 'flippers', 'Allows the user to update a groups flipper (access control)'), ('38', '11', 'folder-listing', 'Allow the user to view ticket list'), ('39', '1', 'login', 'Allow the user to login'), ('40', '1', 'logout', 'Allow the user to log out of the system'), ('41', '15', 'index', '.'), ('42', '1', 'update', 'Allow the user to update any users details'), ('44', '9', 'toggle', 'Allow the user to toggle a flag status for production or development'), ('45', '9', 'update', 'Allow the user to update a flag'), ('46', '9', 'create', 'Allow the user to create a new flag'), ('47', '9', 'delete', 'Allow the user to delete a flag'), ('48', '2', 'index', 'Allow the user to view their own profile'), ('49', '2', 'change-password', 'Allow the user to change their password'), ('50', '11', 'new-folder', 'Allow the user to create folders'), ('51', '11', 'list-folders', 'Allow the user to view a list of their folders in helpdesk'), ('52', '11', 'delete', 'Allows the user to delete a folder in the helpdesk'), ('53', '11', 'view-ticket', 'Allow the user to view a ticket');
COMMIT;

-- ----------------------------
--  Table structure for `providers`
-- ----------------------------
DROP TABLE IF EXISTS `providers`;
CREATE TABLE `providers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `country_id` varchar(3) DEFAULT NULL,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `active` int(11) NOT NULL,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `providers_country_id_idx` (`country_id`),
  CONSTRAINT `providers_ibfk_1` FOREIGN KEY (`country_id`) REFERENCES `countries` (`iso`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

-- ----------------------------
--  Records of `providers`
-- ----------------------------
BEGIN;
INSERT INTO `providers` VALUES ('1', 'ZA', 'Code-Complex', 'admin@code-complex.co.za', '1', '2011-05-29 16:05:43', '2011-05-29 16:05:43');
COMMIT;

-- ----------------------------
--  Table structure for `ticket`
-- ----------------------------
DROP TABLE IF EXISTS `ticket`;
CREATE TABLE `ticket` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `provider_id` int(11) DEFAULT NULL,
  `folder_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `from` varchar(255) NOT NULL,
  `subject` varchar(255) NOT NULL,
  `source` varchar(255) NOT NULL,
  `created` datetime NOT NULL,
  `attachment` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `ticket_provider_id_idx` (`provider_id`),
  KEY `ticket_folder_id_idx` (`folder_id`),
  KEY `ticket_user_id_idx` (`user_id`),
  CONSTRAINT `ticket_ibfk_1` FOREIGN KEY (`provider_id`) REFERENCES `providers` (`id`),
  CONSTRAINT `ticket_ibfk_2` FOREIGN KEY (`folder_id`) REFERENCES `ticket_folders` (`id`),
  CONSTRAINT `ticket_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

-- ----------------------------
--  Records of `ticket`
-- ----------------------------
BEGIN;
INSERT INTO `ticket` VALUES ('1', '1', null, '5', 'root@node1', 'Node 1 Apache server offline', 'email', '2011-07-23 00:43:34', '0'), ('2', '1', '39', '5', 'root@node1', 'Node 1 Apache server online', 'email', '2011-07-24 00:43:55', '0'), ('3', '1', '39', '5', 'root@node2', 'Node 2 Apache server down', 'email', '2011-07-26 23:37:10', '0'), ('4', '1', '38', '5', 'Rina Geers <rina@pretoria-market.co.za>', 'Missing buyers statements', 'email', '2011-07-31 02:09:41', '1'), ('5', '1', null, '5', 'Christo Raath', 'Weekly report', 'internal', '2011-07-31 21:36:57', '1');
COMMIT;

-- ----------------------------
--  Table structure for `ticket_comments`
-- ----------------------------
DROP TABLE IF EXISTS `ticket_comments`;
CREATE TABLE `ticket_comments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ticket_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `comment` longtext NOT NULL,
  `created` datetime NOT NULL,
  `source` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `ticket_comments_ticket_id_idx` (`ticket_id`),
  KEY `ticket_comments_user_id_idx` (`user_id`),
  CONSTRAINT `ticket_comments_ibfk_1` FOREIGN KEY (`ticket_id`) REFERENCES `ticket` (`id`),
  CONSTRAINT `ticket_comments_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

-- ----------------------------
--  Records of `ticket_comments`
-- ----------------------------
BEGIN;
INSERT INTO `ticket_comments` VALUES ('1', '5', '5', 'Please send me your weekly progress report. Thanks.', '2011-07-31 21:36:57', 'user'), ('2', '1', null, 'Apache has been stopped. Please restart the service with the following command: \"/etc/init.d/apache start\"', '2011-07-23 00:43:34', 'email'), ('3', '1', '1', 'I have started up the service again.', '2011-07-23 07:45:23', 'user');
COMMIT;

-- ----------------------------
--  Table structure for `ticket_folders`
-- ----------------------------
DROP TABLE IF EXISTS `ticket_folders`;
CREATE TABLE `ticket_folders` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `parent_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `name` varchar(80) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `ticket_folders_parent_id_idx` (`parent_id`),
  KEY `ticket_folders_user_id_idx` (`user_id`),
  CONSTRAINT `ticket_folders_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `ticket_folders` (`id`),
  CONSTRAINT `ticket_folders_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=latin1;

-- ----------------------------
--  Records of `ticket_folders`
-- ----------------------------
BEGIN;
INSERT INTO `ticket_folders` VALUES ('1', null, '5', 'Client Projects'), ('3', '1', '5', 'Greensleeves'), ('4', '1', '5', 'Trademart'), ('5', null, '5', 'Market Issues'), ('8', '5', '5', 'Durban'), ('9', '5', '5', 'Welkom'), ('30', '1', '5', 'Technofresh'), ('38', '5', '5', 'Pretoria'), ('39', null, '5', 'Server Issues');
COMMIT;

-- ----------------------------
--  Table structure for `users`
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `provider_id` int(11) DEFAULT NULL,
  `firstname` varchar(80) NOT NULL,
  `initials` varchar(10) NOT NULL,
  `surname` varchar(80) NOT NULL,
  `contact_number` varchar(12) NOT NULL,
  `username` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `password` varchar(32) NOT NULL,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  `signature` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `users_provider_id_idx` (`provider_id`),
  CONSTRAINT `users_ibfk_1` FOREIGN KEY (`provider_id`) REFERENCES `providers` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;

-- ----------------------------
--  Records of `users`
-- ----------------------------
BEGIN;
INSERT INTO `users` VALUES ('1', '1', 'Steven', '', 'Inskip', '0825755971', 'Steven', 'inskips@gmail.com', 'f283237689c9f4500e09960cefd2c3cb', '2011-05-01 17:48:32', '2011-05-01 17:48:32', ''), ('5', '1', 'Developer', '', 'User', '0825755971', 'Developer', 'dev@code-complex.co.za', 'f283237689c9f4500e09960cefd2c3cb', '2011-07-28 12:33:08', '2011-07-28 12:33:08', '');
COMMIT;

-- ----------------------------
--  Table structure for `users_groups`
-- ----------------------------
DROP TABLE IF EXISTS `users_groups`;
CREATE TABLE `users_groups` (
  `user_id` int(11) NOT NULL,
  `group_id` int(11) NOT NULL,
  PRIMARY KEY (`user_id`,`group_id`),
  KEY `users_groups_user_id_idx` (`user_id`),
  KEY `users_groups_group_id_idx` (`group_id`),
  CONSTRAINT `users_groups_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
  CONSTRAINT `users_groups_ibfk_2` FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- ----------------------------
--  Records of `users_groups`
-- ----------------------------
BEGIN;
INSERT INTO `users_groups` VALUES ('1', '3'), ('5', '1');
COMMIT;

